<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 15-1-19
 * Time: 上午10:20
 */

namespace Admin\Controller;
use Mcit\Page;

class MsgController extends BaseController {
   public  function index(){
       if(!empty($_GET['name'])){
           // echo I('get.name');
           $map['content'] = array('like','%'.I('get.name').'%');
       }
       $count=D("Msg")->where($map)->relation(true)->count();
//        $model = new Model();
//        $count=$model->query("select * from ev_complain as a,ev_member as b where a.memberID=b.id and b.nickname=".I('get.name'));

       //分页
       vendor('Mcit.Sys.Page');
       $Page = new Page($count, 20);
       $pageView = $Page->show();
       $this->assign('pageView', $pageView); //发送分页
       $nowPage = isset($_GET['page']) ? $_GET['page'] : 1;
       $rs = D("Msg")->where($map)->order("id desc")->relation(true)->page($nowPage . ',' . $Page->listRows)->select();
       //分页结束


       $this->assign("rs",$rs);
       $this->display();

   }

    public  function  sel(){

        $rs=D("Msg")->where("id=".$_POST["id"])->relation(true)->select();
        foreach($rs as $v){
            $con=$v[content];
        }

        if($con){
            echo $con;
        }else{
            echo "0";
        }
    }
    public  function  del(){


        $rs=M("Msg")->where("id=".$_POST["id"])->delete();

        if($rs){
            echo "1";
        }else{
            echo "0";
        }

    }
    public  function add(){

        $this->display();
    }
} 